<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>

    <link rel="stylesheet" href="<%=path %>/css/common.css">
    <link rel="stylesheet" href="<%=path %>/css/main.css">
    <script src="<%=path %>/js/jquery-1.12.4.js"></script>
    <title>Document</title>
    <script type="text/javaScipt">


    </script>
</head>
<body>
<div class="container">

    <div id="forms" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">修改信息</b></div>
                <div class="box_center">


                    <form name="form1" action="<%=path%>/modifyStudentUpdate" method="post" class="jqtransform">
                        <table class="form_table pt15 pb15" width="50%" border="0" cellpadding="0" cellspacing="0">

                            <tr>
                                <td class="td_right">学号：</td>
                                <td class="">
                                    <input type="text" name="id" readonly unselectable="on" class="input-text lh30"
                                           size="40" value="${student.id}">
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">姓名：</td>
                                <td class="">
                                    <input type="text" name="name" value="${student.name}" class="input-text lh30"
                                           size="40">
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">性别：</td>
                                <td class="">
                                    <c:if test="${student.sex=='男'}">
                                        <input type="radio" name="sex" value="男" checked>男
                                        <input type="radio" name="sex" value="女">女
                                    </c:if>

                                    <c:if test="${student.sex=='女'}">
                                        <input type="radio" name="sex" value="男">男
                                        <input type="radio" name="sex" value="女" checked>女
                                    </c:if>

                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">身份证：</td>
                                <td class="">
                                    <input type="text" maxlength="18" name="card" value="${student.card}"
                                           class="input-text lh30" size="40">
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">联系电话：</td>
                                <td class="">
                                    <input type="text" maxlength="20" name="phone" value="${student.phone}"
                                           class="input-text lh30" size="40">
                                </td>
                            </tr>


                            <tr>
                                <td class="td_right">班级：</td>
                                <td class="">
<%--                                    <input type="text" name="banji" value="${student.banji}" class="input-text lh30"
                                           size="40">--%>
                                    <select id="banji" name="banji" class="input-text lh30">
                                        <option disabled>请选择</option>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">学院：</td>
                                <td class="">
<%--                                    <input type="text" name="department" value="${student.department}"
                                           class="input-text lh30" size="40">--%>

                                    <select id="department" name="department" class="input-text lh30">
                                        <option disabled>请选择</option>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">&nbsp;</td>
                                <td class="">
                                    <input type="submit" name="button" class="btn btn82 btn_save2" value="修改">
                                    <input type="button" id="mback_btn" onclick="history.back()" name="button"
                                           class="btn btn82 btn_res bt_right" value="返回">
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var department = document.getElementById("department");
    var banji = document.getElementById("banji");
    $.post("<%=path%>/getAllClasses", {}, function (resp) {
        console.log(resp)
        var dep = [];
        resp.forEach(function (item) {
            if (!dep.includes(item.xueYuan)) {
                dep.push(item.xueYuan)
                if(item.xueYuan=="${student.department}"){
                    department.innerHTML += "<option selected>" + item.xueYuan + "</option>"
                }else {
                    department.innerHTML += "<option>" + item.xueYuan + "</option>"
                }
            }

            if(item.banJi=="${student.banji}"){
                banji.innerHTML+="<option selected>" + item.banJi + "</option>";
            }else {
                banji.innerHTML+="<option>" + item.banJi + "</option>";
            }
        })
    })
</script>
</body>
</html>
  